package Thread;
// 终止线程
public class Demo6 {
    public static boolean isquite = false;
    public static void main(String[] args) {
        Thread t = new Thread(()->{
           while(!isquite) {
               System.out.println("hello thread");
               try {
                   Thread.sleep(1000);
               } catch (InterruptedException e) {
                   e.printStackTrace();
               }
           }
        });
        t.start();
        // 主线程这里执行完一些其他逻辑之后，要让t线程终止
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        //修改前面的标志位
        isquite = true;
        System.out.println("把t线程结束");
    }
}
